<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head th:replace="admin/_fragments :: head(~{::title})">
    <title>types-input</title>
</head>

<body>

    <!-- 导航 -->
    <nav th:replace="admin/_fragments :: menu(3)" >
</nav>

    <div id="new-list" class="ui attached pointing menu">
        <div class="m-container">
            <div class="ui menu">
                <a th:href="@{/admin/types/input}" class="active item">新增</a>
                <a th:href="@{/admin/types}" class="item">列表</a>
            </div>
        </div>
    </div>

    <!-- 中间 -->
    <div id="main" class="m-padding-tb-large ">
        <div class="ui grey m-container m-padding-tb-max">
            <form th:object="${type}" th:action="*{id}==null ? @{/admin/types} : @{/admin/types/{id}(id=*{id})}" method="post" class="ui form"><!--th:action="*{id}==null ? @{/admin/types} : @{/admin/types/{id}(id=*{id})}"-->
<!--                <input type="text" name="id" th:value="*{id}">-->
                <div class="required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">分类名称</label>
                        <input type="text" name="name" placeholder="分类名称" th:value="*{name}">
                    </div>
                </div>

                <div class="ui error message"></div>

                <div class="ui right aligned m-container">
                    <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                    <button class="ui teal submit button">提交</button>
                </div>

            </form>
        </div>
    </div>

    <!-- 底部 -->
    <footer th:replace="admin/_fragments :: footer" class=".m-stick-bottom">
    </footer>

    <th:block th:replace="admin/_fragments :: script">
    </th:block>
    <script>
        $(".btn-sidebar").click(function() {
            $(".m-item").toggleClass("m-mobile-hide");
        });

        $(".ui.dropdown").dropdown({
            on: "hover"
        });

        $(".ui.form").form({
            fields: {
                title: {
                    identifier: "name",
                    rules: [{
                        type: "empty",
                        prompt: "请输入名称"
                    }]
                }
            }
        });

        $(function(){
            getHeight();
        })
        function getHeight(){
            var height = $("nav").height()+$("#new-list").height()+$("#main").innerHeight()+$("footer").height();
            if(height>$(window).height()){
                $("footer").removeClass("m-stick-bottom");
            }else {
                $("footer").addClass("m-stick-bottom");
            };
        }

        /*$(function(){

            $("").click(function(){
                $.ajax({
                    url:'http://127.0.0.1:8000/server',
                    data:{a:0,b:2},
                    type:'POST',
                    dataType:'json',
                    success: function(data){
                        alert(data.a);
                    },
                    timeout:2000,
                    error:function(){
                        console.log("出错了！");
                    }

                });

            })
        })*/
    </script>
</body>

</html>
